﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class User_Accounts : System.Web.UI.Page
{
    BankDataDataContext db = new BankDataDataContext();

    protected void Page_Load(object sender, EventArgs e)
    {
        MembershipUser user = Membership.GetUser();
        var profiles = from profile in db.UserProfiles where profile.userId == (Guid)user.ProviderUserKey select profile;
        if (profiles.Count() != 0)
        {
            SqlDataSourceBankAccounts.SelectParameters["profileId"].DefaultValue = profiles.First().ProfileId.ToString();
        }
    }

    protected void TransferClicked(object sender, EventArgs e)
    {
        LinkButton link = (LinkButton)sender;
        Session.Add("bankAccountId", link.CommandArgument);
        Response.Redirect("~/User/TransferMoney.aspx");
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            LinkButton link = (LinkButton)e.Row.FindControl("TransferLink");
            link.CommandArgument = e.Row.Cells[0].Text;
        }
    }
}